﻿using System;

namespace Td.Additional
{
    /// <summary>
    /// Generic event handler with specified event argument AND sender type
    /// </summary>
    public delegate void TEventHandler<T, U>(T sender, U u) where U : EventArgs;

    /// <summary>
    /// Generiv event argument class with pre specified argument type
    /// </summary>
    /// <typeparam name="T">Argument value type.</typeparam>
    public class EventArgs<T> : EventArgs
    {
        /// <summary>
        /// Gets or sets the value.
        /// </summary>
        /// <value>The value.</value>
        public T Value { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="EventArgs&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="value">The value.</param>
        public EventArgs(T value)
        {
            Value = value;
        }
    }

    /// <summary>
    /// Generiv event argument class with two pre specified argument types
    /// </summary>
    /// <typeparam name="T">First argument value type.</typeparam>
    /// <typeparam name="U">Second argument value type.</typeparam>
    public class EventArgs<T, U> : EventArgs<T>
    {
        /// <summary>
        /// Gets or sets the second value.
        /// </summary>
        /// <value>The second value.</value>
        public U SecondValue { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="EventArgs&lt;T, U&gt;"/> class.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="secondValue">The second value.</param>
        public EventArgs(T value, U secondValue)
            : base(value)
        {
            SecondValue = secondValue;
        }
    }
}
